import {ResponseOperate} from "../../opearte";
import InputStream from "../../stream";
import {channelPacketResp, loginPacketResp, regionPacketResp} from "./resp,packet";

export default  function convert(type:ResponseOperate,stream:InputStream){

    switch (type){

        case ResponseOperate.LOGIN:
            console.info("服务端返回：登录（LOGIN）")
            return loginPacketResp(stream);
        case ResponseOperate.SEND_VERIFICATION_CODE:
            console.info("服务端返回：短信验证码（SEND_VERIFICATION_CODE）")

            return convertResponse(type,stream);
        case ResponseOperate.REAL_NAME_AUTHENTICATION:
            console.info("服务端返回：实名认证（REAL_NAME_AUTHENTICATION）")

            return convertResponse(type,stream);
        case ResponseOperate.LOAD_REGION:
            console.info("服务端返回：加载大区（LOAD_REGION）")

            return regionPacketResp(stream);
            case ResponseOperate.LOAD_CHANNEL:
                console.info("服务端返回：加载频道（LOAD_CHANNEL）")
                return channelPacketResp(stream);
    }
}

export function convertResponse(type:ResponseOperate,stream:InputStream){
    const code=stream.readShort();
    return {type,code}


}